First steps with Liberty-Eiffel

liberty-light

Well, after the release of Liberty-Eiffel as part of GNU I’m giving my first steps with Eiffel language. Some years ago I tried this language, but unfortunately I don’t found documentation in spanish. Now that I can read english, I will give me a try with this language. And, of course, I will also write spanish tutorials for upcoming users 🙂

The first thing I notice is a different terminology. An executable is called system and a set of classes is refereed as universe. The classes can be grouped in clusters into the universe. And the routines (operations) of a class, and its attributes, are called features. The routines are divided in functions or queries (which return a value) and procedures (which do not return a value). As opposed to C language, where we need a function named main, on Eiffel we can designate any procedure to start the execution.

But let start looking the example “Hello World!” that comes in the source tarball. First install Liberty-Eiffel, in my case I have the deb packages from Snapshots, because the stable packages for i386 are broken. The example is this, from — to the end of the lines are comments (I removed the original comments, but add others for explanation):

eiffel1

{ANY} mean that any other class can call this routine. In Eiffel we can limit the calls from certain classes. io is a class for input/output and the routine put_string write a message at default output. The source tarball, at work/eiffel.el, provide a major mode for Emacs. Save this program in a file with the name hello_world.e and compile this with:

se compile hello_world.e -o hello

In Eiffel is recommended have one class per file. The name of class capitalized and the name of the corresponding file in lowercase. Now run the executable:

./hello
Hello World.

Clap clap, our first program with Eiffel.

OK, here happened something magic. We don’t set any routine as the initial to start the execution. Liberty-Eiffel don’t implement 100% the ECMA standard in which, if the initial routine isn’t specified, is assumed it has the name make. So, I suppose in Liberty-Eiffel it is assumed to have the name main. But go ahead, Liberty use ACE files with the same purpose of makefiles in other languages. This is our ACE file for this example:

eiffel2

Again, from — to the end of the lines are comments. In cluster section there are two lines. The current directory, where is our file hello_world.e, and the paths of Liberty libraries, defined in loadpath.se. Save this file in the same directory of our source file, and with the extension ace, for example hello.ace: Now you can compile the program with:

se compile hello.ace

To clean the compile products, except the executable, use:

se clean *.e

And that is all for now. In next posts I will share other examples while I learn this interesting language. Regards 🙂

3 thoughts on “First steps with Liberty-Eiffel

  1. Pingback: German Arias: First steps with Liberty-Eiffel | Open World
  2. Pingback: Links 18/7/2014: Slackware Turns 21, Spotify Switches to Ubuntu | Techrights

Leave a comment